package assignment;

import java.util.concurrent.CountDownLatch;

public class HomeworkStaticCountDownLatch {
	private static int result;
	public static void main(String [] args) throws InterruptedException{
		CountDownLatch cdl = new CountDownLatch(1);
		class CountDownTask implements Runnable{
			private CountDownLatch latch;
			CountDownTask(CountDownLatch latch){
				this.latch = latch;
			}
			public void run() {
				result = sum();
				this.latch.countDown();
			}
			
		};
		long start = System.currentTimeMillis();
		Thread t = new Thread(new CountDownTask(cdl));
		t.start();
		cdl.await();
		System.out.println("result==>" + result);
		System.out.println("Use mills==>"+(System.currentTimeMillis()-start));
	}
	
	public static int sum() {
		return fibo(36);
	}
	
	public static int fibo(int a) {
		if(a<2)
			return 1;
		return fibo(a-1)+fibo(a-2);
	} 
}
